<!--
	상품리스트 페이지
	작성자:문연지
	작성일:2014/10/25
 -->
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>장돌뱅이 ~대한민국 전통시장을 응원합니다~</title>
<style type="text/css">
#content{
	width:1100px;
	margin:0 auto;	
}
.line_table{
	width:100%;
	border-bottom:1px solid #bfbfbf;
}
#line_td_table{
	width:100%;
	border-bottom:2px solid #bfbfbf;
	margin-top:5px;
}

/*상세검색 DIV*/
#div_searching{
	width:1100px;
	margin:0 auto;
	text-align: center;
	margin-top:50px;
	margin-bottom:50px;
}
#div_tb_searching{
	width:1100px;
	margin:0 auto;
	text-align: center;
}
#tb_searching{
	
}


/*검색결과 DIV*/
#div_results{
	margin-top:50px;
}
#span_results{
	margin-top:10px;
	margin-bottom:10px;
	font-size:20pt;
	font-family:anew;
}
#tb_results_category{
	font-family:anew;
	font-size:13pt;
	margin-top:20px;
	margin-bottom:10px;
}
#tb_results{
	margin-top:50px;
	margin-bottom:50px;
}
tr{
	margin-top:5px;
	margin-bottom:5px;
}
</style>
<script type="text/javascript" src="/Jangdolbaeng2/js/jquery-1.11.1.js"></script>
<script type="text/javascript">

var keyword = '${keyword}';
keyword = keyword.substring(1,keyword.length-1);

$(document).ready(function(){
	
	var size = <s:property value="product_list.size"/>;
	if(size==0){
		alert('검색결과가 없습니다.');
		history.back();
	}
	
	$('#text_search').val(keyword);
	
});


/*수량 올리는 펑션*/
function quantityup(product_seq){
	var quantity = $('#quantitytext'+product_seq).val();
	quantity = ++quantity;
	$('#quantitytext'+product_seq).val(quantity);
}
function quantitydown(product_seq){
	var quantity = $('#quantitytext'+product_seq).val();
	if(quantity > 1){
		quantity = --quantity;
		$('#quantitytext'+product_seq).val(quantity);
	}
}

/*장바구니 보내는 펑션*/
function goCartbt(product_seq){
	var customer_id = '${session.customer_id}';
	
	if(customer_id.length==0){
		if(confirm('로그인이 필요한 기능입니다. \n로그인 하시겠습니까?')){
			window.open("/Jangdolbaeng2/customer/goLoginForm.action", "loginWin", 
					"width=800,height=380,top=300,left=500,scrollbars=no");
			return;
		}else{
			return;
		}
	}
	var quantity = $('#quantitytext'+product_seq).val();
	$.ajax({
		url:'/Jangdolbaeng2/product/insertCart.action',
		type:'post',
		dataType:'json',
		data:{
			quantity:quantity,
			product_seq:product_seq
		},
		success:function(json){
			if(confirm('장바구니에 넣었습니다.\n장바구니로 이동하시겠습니까?')){
				location.href="/Jangdolbaeng2/customer/goCart.action";
			}else{
				$('#quantitytext'+product_seq).val(1);
			}
		}
	});
}

function showTheCategoryResult(category){
	location.href="/Jangdolbaeng2/product/getTheCategoryResult.action?category="+category+"&keyword="+keyword;
}

</script>
</head>
<body>
<div id="head">
<%@ include file="/jsp/customer/main_header.jsp" %>
</div>
<div id="content">
	<div id="div_results" align="center">
		<span class="glyphicon glyphicon-search">
		<span id="span_results">검색 결과는 총 <s:property value="product_list.size"/>개 입니다.</span>
		</span>
		
		<table id="tb_results_category">
		<tr>
		<s:iterator value="result_category_list">
			<td width="100px;" align="center">
			<a href="javascript:showTheCategoryResult('<s:property value="CATEGORY_KEY"/>')">
			<s:property value="CATEGORY_VALUE"/>
			(<s:property value="COUNT"/>)</a>
			</td>
		</s:iterator>
		</tr>
		</table>
		
		<div id="forIterator">
		<table id="tb_results" width="1000px">
		<tr><td align="center" width="70px">종류</td>
			<td align="center" colspan="2">이름</td>
			<td align="center" width="120px">가격</td>
			<td align="center" width="150px">상점</td>
			<td align="center" colspan="4"></td>
		</tr>
		<tr><td colspan="9"><div id="line_td_table"/></td></tr>
		<s:iterator value="product_list">
		<tr><td align="center"><s:property value="CATEGORY_VALUE"/></td>
			<td width="60px" style="margin-right:5px; margin-left:5px;">
				<a href="/Jangdolbaeng2/product/goProduct_detail.action?product_seq=<s:property value="PRODUCT_SEQ"/>">
				<img src="data:image/jpeg;base64,<s:property value="PRODUCT_IMAGE1"/>" 
					height="50px" style=" margin-top:10px; margin-bottom:10px;"/></a>
			</td>
			<td><a href="/Jangdolbaeng2/product/goProduct_detail.action?product_seq=<s:property value="PRODUCT_SEQ"/>">
				<s:property value="PRODUCT_NAME"/></a>
			</td>
			<td align="right" style="margin-right:5px;"><s:property value="PRODUCT_PRICE"/></td>
			<td align="center" style="margin-left:5px;">
				<a href="/Jangdolbaeng2/seller/blogMain.action?shop_seq=<s:property value="SHOP_SEQ"/>">
				<s:property value="NAME"/>
				</a>
			</td>
			<td width="70px" align="right">수량
			<input type="text" id="quantitytext<s:property value="PRODUCT_SEQ"/>" value="1" size="3" class="input_text">
			</td>
			<td width="22px" align="right">
				<img src="/Jangdolbaeng2/img/customer/upDown.jpg" usemap="#updownLink<s:property value="PRODUCT_SEQ"/>">
			</td>
			<td><map name="updownLink<s:property value="PRODUCT_SEQ"/>">
            		<area shape="rect" coords="4,4,13,12" href="javascript:quantityup(<s:property value="PRODUCT_SEQ"/>)">
            		<area shape="rect" coords="4,14,13,22" href="javascript:quantitydown(<s:property value="PRODUCT_SEQ"/>)">
       			</map>
       		</td>
			<td width="50px">
				<a href="javascript:goCartbt(<s:property value="PRODUCT_SEQ"/>)">
				<button type="button" class="btn btn-default navbar-btn" 
						style="color:#383838; background-color:#fcfcfc; font-size:8pt; font-family:nanumBB; 
						padding-left:5px;padding-right: 5px; padding-top:0px; padding-bottom: 0px;">장바구니</button></a>
			</td>
		</tr>
		<tr><td colspan="9" width="2px"><div class="line_table"/></td></tr>
		</s:iterator>
		</table>
		</div>
	</div>
</div>
<div id="footer">
	<%@ include file="/jsp/customer/main_footer.jsp" %>
</div>
</body>
</html>